<H2>Does Jetty support virtual hosts?</H2>
<P>
Many domain names can be mapped to a single TCP/IP address.  If
different content needs to be served for each different domain, then the virtual
hosts mechanism needs to be used.
<P>
A HttpContext can be registered against one or more virtual host names. Only
requests that have a matching host header or fully qualified URL will be
passed to that context.
<P>
The setVirtualHosts method can be used to set an array of virtual host names
on a Context. In the jetty.xml file, this can be
done with:
<UL><TT><PRE>
  &lt;Call name="addWebApplication"&gt;
    &lt;Arg&gt;/context&lt;/Arg&gt;
    &lt;Arg&gt;./webapps/myapp&lt;/Arg&gt;

    &lt;Set name="virtualHosts"&gt;
      &lt;Array type="java.lang.String"&gt;
        &lt;Item&gt;www.acme.com&lt;/Item&gt;
        &lt;Item&gt;acme.com&lt;/Item&gt;
        &lt;Item&gt;www.wileyc.com&lt;/Item&gt;
        &lt;Item&gt;184.34.51.125&lt;/Item&gt;
      &lt;/Array&gt;
    &lt;/Set&gt;
  &lt;/Call&gt;
</PRE></UL></TT>
<P>
A null virtual host name is the same as no virtual host names and means the
context is available to requests that do not first match other virtual host contexts. 
<P>
If you want different content to be served from different real IP addresses,
then you do not need virtual hosts. Rather you need multiple instances of
HttpServer, each with their own listeners and contexts.


<P>

<A HREF="index.html" TITLE="Back to JettyFAQ"><IMG SRC="/jetty/images/info_sm.gif" BORDER="0"><BR
CLEAR="bottom"> JettyFaq</A>
<BR><BR>
